package table.creators;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import controllers.AuthorHelper;
import models.Checkout;
import models.Dispatch;
import controllers.Helper;
import controllers.TableModel;
import controllers.TableModel.AoColum;

public class CheckoutTable {

    public static TableModel create(String current_user) {
    
        final String title = "车款结算";
        String today = Helper.dateToString(new Date());
        String now = Helper.datetimeToString(new Date());

        List<AoColum> colums = new ArrayList<AoColum>();
        TableModel model = new TableModel();

        //                           name,             title,         required,     defaut,        cansearch, editable,    edit_type,    edit_data,            editable_settings    
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("id",    "编号",    false,    "",    false,    false,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("dispatch.id",    "调度编号",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Dispatch.getIdJson(),    null,  "ONEBOX",  "dispatch",  "id",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("dispatch.customer.name",    "用车单位",    true,    "",    true,    false,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("dispatch.vehicle.plate_number",    "车号",    true,    "",    false,    false,    "select",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("dispatch.start_date",    "开始日期",    true,    "",    true,    false,    "date",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("dispatch.end_date",    "结束日期",    true,    "",    true,    false,    "date",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("use_days",    "用车天数",    true,    "",    false,    false,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("dispatch.checkout_charge",    "车价合计",    true,    "",    false,    false,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("income",    "现收车款",    true,    "",    false,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        model.buildModel(Checkout.class, 600, title, AuthorHelper.canDo(current_user, title, "增加"), AuthorHelper.canDo(current_user, title, "搜索"), AuthorHelper.canDo(current_user, title, "删除"), colums);
        return model;
    }
}

